<?php
	require_once('auth.php');
?>
<?php
//checking connection and connecting to a database
require_once('connection/config.php');
//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}
//get member id from session
$memberId=$_SESSION['SESS_MEMBER_ID'];

//selecting all records from the orders_details table. Return an error if there are no records in the table
$result=mysql_query("SELECT * FROM orders_details WHERE member_id='$memberId'")
or die("There are no records to display ... \n" . mysql_error()); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pizza-Inn:Member Home</title>
<link href="stylesheets/user_styles.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="validation/user.js">
</script>
</head>
<body>
<div id="page">
  <div id="menu"><ul>
  <li><a href="home.htm">Home</a></li>
  <li><a href="pizzazone.php">Pizza Zone</a></li>
  <li><a href="specialdeals.php">Special Deals</a></li>
  <li><a href="login-form.php">Login</a></li>
  <li><a href="register-form.php">Register</a></li>
  <li><a href="member-index.php">My Account</a></li>
  <li><a href="contactus.htm">Contact Us</a></li>
  </ul>
  </div>
<div id="header">
  <div id="logo"> <a href="home.htm" class="blockLink"></a></div>
  <div id="company_name">Pizza-Inn Restaurant</div>
</div>
<div id="center">
<h1>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1>
  <div style="border:#bd6f2f solid 1px;padding:4px 6px 2px 6px">
<a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a>
<p>&nbsp;</p>
<p>Here you can view order history and delete old orders from your account. Invoices can be viewed from the order history. You can also make table reservations in your account. For more information <a href="contactus.htm">Click Here</a> to contact us.
<h3><a href="pizzazone.php">Click Here to Order More Pizza</a></h3>
<hr>
<table border="0" width="600" align="center">
<CAPTION><h2>ORDER HISTORY</h2></CAPTION>
<tr>
<th>Order Id</th>
<th>Pizza Type</th>
<th>Price</th>
<th>Quantity</th>
<th>Total Cost</th>
<th>Delivery Date</th>
</tr>

<?php
//loop through all table rows
while ($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Order_Id']."</td>";
echo "<td>" . $row['Pizza_Type']."</td>";
echo "<td>" . $row['Price']."</td>";
echo "<td>" . $row['Quantity']."</td>";
echo "<td>" . $row['Total_Cost']."</td>";
echo "<td>" . $row['Order_Date']."</td>";
echo '<td><a href="delete-order.php?id=' . $row['Order_Id'] . '">Delete Order</a></td>';
echo "</tr>";
}
mysql_free_result($result);
mysql_close($link);
?>
</table>
<hr>
<form name="reserveForm" id="reserveForm" method="post" action="reserve-exec.php?id=<?php echo $_SESSION['SESS_MEMBER_ID'];?>" onsubmit="return reserveValidate(this)">
<table align="center" width="300">
<CAPTION><h2>RESERVE A TABLE</h2></CAPTION>
<tr>
	<td><b>Select Table Number:</b></td>
	<td>
	<SELECT NAME="tNumber" id="tNumber">
	<OPTION VALUE="select">select
	<OPTION VALUE="1">1
	<OPTION VALUE="2">2
	<OPTION VALUE="3">3
	<OPTION VALUE="4">4
	<OPTION VALUE="2">5
	<OPTION VALUE="3">6
	<OPTION VALUE="4">7
	</SELECT>
	</td>
</tr>
<tr>
	<td><b>Date:</b></td><td><input type="date" value="2012-03-25" name="date" id="date" /></td></tr>
<tr>
	<td><b>Time:</b></td><td><input type="time" value="09:00" name="time" id="time" />
	</td>
</tr>
<tr>
	<td colspan="2" align="center"><input type="submit" value="Reserve"></td>
</tr>
</table>
</form>
<hr>
<form name="ratingForm" id="ratingForm" method="post" action="rating-exec.php?id=<?php echo $_SESSION['SESS_MEMBER_ID'];?>" onsubmit="return ratingValidate(this)" style="text-align:center;">
<table align="center" width="200">
<CAPTION><h2>RATE OUR SERVICE</h2></CAPTION>
<tr>
	<td>Excellent</td>
	<td><input type="radio" name="rate" id="rate" value="excellent" /></td>
</tr>
<tr>
	<td>Good</td>
	<td><input type="radio" name="rate" id="rate" value="good" /></td>
</tr>
<tr>
	<td>Average</td>
	<td><input type="radio" name="rate" id="rate" value="average" /></td>
</tr>
<tr>
	<td>Bad</td>
	<td><input type="radio" name="rate" id="rate" value="bad" /></td>
</tr>
<tr>
	<td>Worse</td>
	<td><input type="radio" name="rate" id="rate" value="worse" /></td>
</tr>
<tr>
	<td colspan="2"><input type="submit" name="Submit" value="Rate" /></td>
</td>
</table>
</form>
</div>
</div>
<div id="footer">
    <div class="bottom_menu"><a href="home.htm">Home Page</a>  |  <a href="aboutus.htm">About Us</a>  |  <a href="specialdeals.htm">Special Deals</a>  |  <a href="pizzazone.php">Pizza Zone</a>  |  <a href="#">Affiliate Program</a> |<br>
  | <a href="admin/index.php" target="_blank">Administrator</a> |</div>
  
  <div class="bottom_addr">&copy; 2012 Pizza-Inn. All Rights Reserved</div>
</div>
</div>
</body>
</html>
